package com.xxx.file;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/22 15:17
 * @Copyright 博为峰
 */
public class FileOutputStreamDemo {
    public static void main(String[] args) {
//        m1();
        try (FileInputStream fileInputStream = new FileInputStream("./IO/fos.txt")) {
            byte[] bytes = new byte[1024];
            int count = 0;
            while ((count = fileInputStream.read(bytes)) != -1) {
                System.out.println(new String(bytes, 0, count));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        //fos.txt 复制一份fos2.txt
    }

    public static void m1() {
        try (FileOutputStream fileOutputStream = new FileOutputStream("./IO/fos.txt")) {
            fileOutputStream.write("你好".getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
